From c00341e69234028616f5ea20500099f9c141d24d Mon Sep 17 00:00:00 2001 From: Andres Lagar-Cavilla Date: Thu, 24 Nov 2011 15:20:57 +0000 Subject: [PATCH] x86/mm/p2m: don't overwrite m2p entry of still-shared pages When updating a p2m mapping to shared, previous code unconditionally set the m2p entry for the old mfn to invalid. We now check that the old mfn does not remain shared. Signed-off-by: Andres Lagar-Cavilla Acked-by: Tim Deegan Committed-by: Tim Deegan --- xen/arch/x86/mm/p2m.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 51a0096e6c..f33b773618 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -714,8 +714,9 @@ set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) * sharable first */ ASSERT(p2m_is_shared(ot)); ASSERT(mfn_valid(omfn)); - /* XXX: M2P translations have to be handled properly for shared pages */ - set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY); + if ( ((mfn_to_page(omfn)->u.inuse.type_info & PGT_type_mask) + != PGT_shared_page) ) + set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY); P2M_DEBUG("set shared %lx %lx\n", gfn, mfn_x(mfn)); rc = set_p2m_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_shared, p2m->default_access); -- 2.30.2